package com.houseman.workFlow.processer.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.houseman.workFlow.bean.ApprovalInfo;
import com.houseman.workFlow.processer.Processer;
import com.houseman.workFlow.service.ApproveService;
import com.houseman.workFlow.service.impl.ApproveServiceImpl;

/**
 * 请求流程处理
 * 返回流程处理页面，再由处理页面的iframe访问处理类
 */
public class RequestProcesser extends Processer{

	//service
	ApproveService service = new ApproveServiceImpl();
	@Override
	public void proccess(HttpServletRequest request, HttpServletResponse response) {
		//设置流程workId
		String graphId = request.getParameter("graphId");
		String workId = request.getParameter("workId");
		
		try {
			if(graphId == null || "".equals(graphId)) {
				request.setAttribute("workId", workId);
				
				//添加工作流审批信息
				List<ApprovalInfo> appInfos = service.queryAppInfoByWorkId(new Integer(workId));
				request.setAttribute("appInfos", appInfos);
			}else {
				request.setAttribute("graphId", graphId);
			}
			
			request.getRequestDispatcher("/WEB-INF/workFlow/page/process.jsp").forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
